/**
 * Company
 * Copyright (C) 1992-2020 All Rights Reserved.
 */
package com.yinhai.mycat_test.service.read.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yinhai.mycat_test.VO.OrderVO;
import com.yinhai.mycat_test.VO.PageVO;
import com.yinhai.mycat_test.entity.Order;
import com.yinhai.mycat_test.mapper.read.OrderReadMapper;
import com.yinhai.mycat_test.service.read.OrderReadService;

/**
 * @author wanggan@yinhai.com
 * @version 1.0
 * @date 2020/4/9 17:19
 * @since JDK1.8
 */
@Service
public class OrderReadServiceImpl implements OrderReadService {
    
    @Autowired
    private OrderReadMapper orderReadMapper;
    
    @Override
    public List<Order> queryOrderLikeOrderId(Long orderId) {
        return orderReadMapper.queryOrderIdLike01(orderId);
    }
    
    @Override
    public List<Order> queryOrderLikeOrderItemName(OrderVO orderVO) {
        return orderReadMapper.queryOrderNameLike02(orderVO.getUserId(),orderVO.getOrderItemName());
    }
    
    @Override
    public Integer queryOrderCount() {
        return orderReadMapper.queryOrderCount();
    }
    
    @Override
    public Integer queryOrderCountByUserId(Long userId) {
        return orderReadMapper.queryOrderCountByUserId(userId);
    }
    
    @Override
    public IPage<Order> listOrderByUserId(OrderVO orderVO) {
        IPage<Order> page = new Page<>(orderVO.getPageNum(),orderVO.getPageSize());
        return orderReadMapper.queryAllOrderByUserId(page,orderVO.getUserId());
    }
    
    @Override
    public Order querOrderByOrderId(Long orderId) {
        return orderReadMapper.queryOneOrder(orderId);
    }
    
    @Override
    public IPage<Order> listAllOrder(PageVO pageVo) {
        IPage<Order> page = new Page<>(pageVo.getPageNum(),pageVo.getPageSize());
        return orderReadMapper.queryAllOrder(page);
    }
}
